<!DOCTYPE html>
<html lang="ch">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //6、var arr = [4, 0, 7, 9, 0, 0, 2, 6, 0, 3, 1, 0];
        //要求将数组中的0项去掉，将不为0的值存入一个新的数组，生成新的数组

        arr=[4,0,7,9,0,0,2,6,0,3,1,0];
       var a=[];
       for(i=0;i<arr.length;i++){
        if(arr[i]!=0){
            a.push(arr[i])
        }
       }
       console.log(a);
    </script>
</body>
</html>